package com.shujia.mllib

import java.io.StringReader

import org.wltea.analyzer.core.{IKSegmenter, Lexeme}

import scala.collection.mutable.ListBuffer

object Demo9IK {

  def main(args: Array[String]): Unit = {

    val text = "数加学院牛逼"

    println(fit(text))

  }

  def fit(text: String): List[String] = {

    val words = new ListBuffer[String]

    val sr = new StringReader(text)
    val ik = new IKSegmenter(sr, true)

    //取第一个次
    var lexeme: Lexeme = ik.next()

    while (lexeme != null) {
      val word: String = lexeme.getLexemeText

      words += word

      //取下一个
      lexeme = ik.next()
    }

    words.toList
  }
}
